/* GUI CONVERTED from soivrp10.p (converter v1.76) Wed May 21 19:20:16 2003 */
/* soivrp10.p  -  INVOICE HISTORY INVOICE REPRINT                             */
/* Copyright 1986-2003 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.19.1.15 $                                                     */
/*V8:ConvertMode=Report                                                       */
/* REVISION: 5.0      LAST MODIFIED: 01/05/90   BY: ftb *B511*                */
/* REVISION: 6.0      LAST MODIFIED: 04/16/90   BY: ftb *D002*                */
/* REVISION: 6.0      LAST MODIFIED: 07/05/90   BY: WUG *D043*                */
/* REVISION: 6.0      LAST MODIFIED: 08/15/90   BY: ftb *B773*                */
/* REVISION: 6.0      LAST MODIFIED: 09/18/90   BY: MLB *D055*                */
/* REVISION: 6.0      LAST MODIFIED: 03/12/91   BY: afs *D425*                */
/* REVISION: 6.0      LAST MODIFIED: 04/10/91   BY: MLV *D506    (rev only)   */
/* REVISION: 6.0      LAST MODIFIED: 05/09/91   BY: MLV *D617*                */
/* REVISION: 7.0      LAST MODIFIED: 10/21/91   BY: afs *D903*   (rev only)   */
/* REVISION: 7.0      LAST MODIFIED: 02/13/92   BY: tjs *F191*   (rev only)   */
/* REVISION: 7.0      LAST MODIFIED: 03/04/92   BY: tjs *F247*   (rev only)   */
/* REVISION: 7.0      LAST MODIFIED: 03/20/92   BY: TMD *F263*   (rev only)   */
/* REVISION: 7.0      LAST MODIFIED: 03/04/92   BY: tjs *F320*   (rev only)   */
/* REVISION: 7.0      LAST MODIFIED: 03/27/92   BY: dld *F322*                */
/* REVISION: 7.0      LAST MODIFIED: 04/02/92   BY: afs *F348*                */
/* REVISION: 7.0      LAST MODIFIED: 04/08/92   BY: tmd *F367*   (rev only)   */
/* REVISION: 7.0      LAST MODIFIED: 06/19/92   BY: tmd *F458*   (rev only)   */
/* REVISION: 7.3      LAST MODIFIED: 09/04/92   BY: afs *G047*                */
/* REVISION: 7.3      LAST MODIFIED: 02/19/93   by: jms *G712*                */
/* REVISION: 7.3      LAST MODIFIED: 03/11/93   BY: afs *G805*                */
/* REVISION: 7.3      LAST MODIFIED: 03/17/93   BY: afs *G820*   (rev only)   */
/* REVISION: 7.3      LAST MODIFIED: 04/29/93   BY: bcm *GA56*   (rev only)   */
/* REVISION: 7.3      LAST MODIFIED: 05/13/93   BY: kgs *GA93*                */
/* REVISION: 7.3      LAST MODIFIED: 06/11/93   BY: WUG *GB74*                */
/* REVISION: 7.4      LAST MODIFIED: 08/19/93   BY: pcd *H009*                */
/* REVISION: 7.4      LAST MODIFIED: 10/28/93   BY: cdt *H197*                */
/* REVISION: 7.4      LAST MODIFIED: 05/19/94   BY: afs *FO31*                */
/* REVISION: 7.4      LAST MODIFIED: 06/02/94   BY: dpm *GK02*                */
/* REVISION: 7.3      LAST MODIFIED: 09/08/94   BY: dpm *FQ87*                */
/* REVISION: 7.4      LAST MODIFIED: 09/10/94   BY: bcm *GM05*                */
/* REVISION: 7.4      LAST MODIFIED: 10/18/94   BY: jzs *GN91*                */
/* REVISION: 8.5      LAST MODIFIED: 03/31/95   BY: nte *J042*                */
/* REVISION: 8.5      LAST MODIFIED  05/10/95   BY: jym *G0MF*                */
/* REVISION: 8.5      LAST MODIFIED: 07/26/95   BY: taf *J053*                */
/* REVISION: 8.5      LAST MODIFIED: 01/08/96   BY: *J04C* Sue Poland         */
/* REVISION: 8.5      LAST MODIFIED: 04/22/96   BY: bxw *J0JY*                */
/* REVISION: 8.5      LAST MODIFIED: 10/21/96   BY: *J15C* Markus Barone      */
/* REVISION: 8.5      LAST MODIFIED: 10/20/97   BY: *H1F8* Nirav Parikh       */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 04/23/98   BY: *L00L* EvdGevel           */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 07/14/98   BY: *L024* Steve Goeke        */
/* REVISION: 9.1      LAST MODIFIED: 06/01/99   BY: *K20C* Chris Green        */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 06/28/00   BY: *N0DM* Mudit Mehta        */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KN* myb                */
/* REVISION: 9.1      LAST MODIFIED: 10/13/00   BY: *N0W8* Mudit Mehta        */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Revision: 1.19.1.11     BY: Katie Hilbert     DATE: 04/01/01  ECO: *P002*  */
/* Revision: 1.19.1.12     BY: Manisha Sawant    DATE: 05/08/01  ECO: *N0YD*  */
/* Revision: 1.19.1.13   BY: Jean Miller       DATE: 05/14/02  ECO: *P05V*  */
/* Revision: 1.19.1.14   BY: Dorota Hohol   DATE: 02/25/03  ECO: *P0N6* */
/* $Revision: 1.19.1.15 $  BY: Narathip W.    DATE: 05/13/03  ECO: *P0RT* */

/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* DISPLAY TITLE */

/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "2+ "}
{cxcustom.i "SOIVRP10.P"}

define new shared variable rndmthd like rnd_rnd_mthd.
define new shared variable oldcurr like ih_curr.
define new shared variable due_date like idh_due_date.
define new shared variable due_date1 like idh_due_date.
define new shared variable inv like idh_inv_nbr.
define new shared variable inv1 like idh_inv_nbr.
define new shared variable nbr like ih_nbr.
define new shared variable nbr1 like ih_nbr.
define new shared variable site like ih_site.
define new shared variable site1 like ih_site.
define new shared variable print_lotserials like mfc_logical initial no
   label "Print Lot/Serial Numbers Shipped".
define new shared variable first_line like mfc_logical.
define new shared variable pages as integer.
define new shared variable comp_addr like soc_company.
define new shared variable msg like msg_desc.
define new shared variable inv_date like ih_inv_date.
define new shared variable inv_date1 like ih_inv_date.
define new shared variable ih_recno as recid.
define new shared variable company as character format "x(38)" extent 6.
define new shared variable billto as character format "x(38)" extent 6.
define new shared variable soldto as character format "x(38)" extent 6.
define new shared variable termsdesc like ct_desc.
define new shared variable shipdate like ih_ship_date.
define new shared variable shipdate1 like shipdate.
define new shared variable addr as character format "x(38)" extent 6.
define new shared variable print_options like mfc_logical initial no
   label "Print Features and Options".
define new shared variable override_print_hist like mfc_logical
   label "Override Print Inv Hist".
define new shared variable hdr_po as character format "X(38)".
define new shared variable cust  like ih_cust.
define new shared variable cust1 like ih_cust.
define new shared variable bill  like ih_bill.
define new shared variable bill1 like ih_bill.
define new shared variable resale like cm_resale.
define new shared variable base_rpt as character.
{&SOIVRP10-P-TAG10}

{etvar.i &new="new"}
{etdcrvar.i "new"}

{soivtot1.i "NEW" }  /* Define variables for invoice totals. */

/* DEFINE VARIABLES FOR DISPLAY OF VAT REG NO & COUNTRY CODE */
{gpvtegl.i}
{gpvtecdf.i &var="new shared"}
{gpvtepdf.i &var="new shared"}

define new shared variable incinv like mfc_logical initial yes
   label "Include Debit Invoices".
define new shared variable incmemo like mfc_logical initial yes
   label "Include Credit Invoices".
define new shared variable disc_det_key  like lngd_key1
   initial "1".
define new shared variable disc_sum_key  like lngd_key1
   initial "1".
define new shared variable call-detail  like mfc_logical
   label "Print Call Invoice Detail" initial no.

define variable disc_det      like lngd_translation label "Discount Detail".
define variable disc_sum      like disc_det         label "Discount Summary".

define new shared frame phead1.

{&SOIVRP10-P-TAG20}
define variable form_code    as character format "x(2)" label "Form Code" no-undo.
{&SOIVRP10-P-TAG21}
define variable run_file     as character format "x(12)" no-undo.
define variable prt_width    as integer no-undo.
define variable program_name as character initial 'soprint.p' no-undo.
define variable l_label      as character no-undo.


{&SOIVRP10-P-TAG19}
l_label = getTermLabel("D_U_P_L_I_C_A_T_E",35).
assign
   msg = fill(" ", integer((52 - length(l_label)) / 2)) +
         "* * * " + l_label + " * * *".

{&SOIVRP10-P-TAG1}
{&SOIVRP10-P-TAG22}

/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
inv                 colon 15
   inv1                label "To"       colon 49 skip
   nbr                 colon 15
   nbr1                label "To"       colon 49 skip
   shipdate            colon 15
   shipdate1           label "To"       colon 49 skip
   site                colon 15
   site1               label "To"       colon 49 skip
   cust                colon 15
   cust1               label "To"       colon 49 skip
   bill                colon 15
   bill1               label "To"       colon 49
   inv_date            colon 15
   inv_date1           label "To"       colon 49
   print_lotserials    colon 35 incinv  colon 70 skip
   print_options       colon 35 incmemo colon 70 skip
   override_print_hist colon 35 skip
   comp_addr           colon 35
   form_code           colon 60 deblank skip
   disc_det            colon 35
   disc_sum            colon 35
   call-detail         colon 35 skip
   space(1)
   msg            skip
with frame a side-labels width 80 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME


{&SOIVRP10-P-TAG23}
{&SOIVRP10-P-TAG2}

/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

find first lngd_det where
       lngd_dataset = program_name
   and lngd_field   = "det_disc_prnt"
   and lngd_lang    = global_user_lang
   and lngd_key1    = disc_det_key
no-lock no-error.
if available lngd_det then
   disc_det = lngd_translation.
else
   disc_det = "".

find first lngd_det where lngd_dataset = program_name
   and lngd_field   = "det_disc_prnt"
   and lngd_lang    = global_user_lang
   and lngd_key1    = disc_sum_key
   no-lock no-error.
if available lngd_det then
   disc_sum = lngd_translation.
else
   disc_sum = "".

{&SOIVRP10-P-TAG11}

{&SOIVRP10-P-TAG24}
repeat:

   oldcurr = "".
   if inv1 = hi_char then inv1 = "".
   if nbr1 = hi_char then nbr1 = "".
   if inv_date = low_date then inv_date = ?.
   if inv_date1 = hi_date then inv_date1 = ?.
   if shipdate = low_date then shipdate = ?.
   if shipdate1 = hi_date then shipdate1 = ?.
   if site1 = hi_char then site1 = "".
   if cust1 = hi_char then cust1 = "".
   if bill1 = hi_char then bill1 = "".
   if form_code = "" then form_code = "1".
   if comp_addr = "" then do:
      find first soc_ctrl no-lock.
      comp_addr = soc_comp.
   end.

   {&SOIVRP10-P-TAG3}
   {&SOIVRP10-P-TAG25}
   update
      inv inv1 nbr nbr1 shipdate shipdate1
      site site1
      cust cust1 bill bill1
      inv_date inv_date1
      print_lotserials print_options
      override_print_hist
      comp_addr
      form_code
      incinv incmemo
      disc_det disc_sum
      call-detail
      msg
   with frame a
   editing:

      {&SOIVRP10-P-TAG4}

      {&SOIVRP10-P-TAG12}


      if frame-field = "disc_det" then do:
         {mfnp05.i lngd_det lngd_trans
            "    lngd_dataset = program_name
             and lngd_field   = 'det_disc_prnt'
             and lngd_lang    = global_user_lang"
            lngd_translation "input disc_det" }
         if recno <> ? then
         display lngd_translation @ disc_det
         with frame a.
      end.

      else if frame-field = "disc_sum" then do:
         {mfnp05.i lngd_det lngd_trans
            "    lngd_dataset = program_name
             and lngd_field   = 'det_disc_prnt'
             and lngd_lang    = global_user_lang"
            lngd_translation "input disc_sum" }
         if recno <> ? then display lngd_translation @ disc_sum
         with frame a.
      end.

      else do:
         status input.
         readkey.
         apply lastkey.
      end.

   end.

   {&SOIVRP10-P-TAG26}
   /* Validate discount print options */
   find first lngd_det where
          lngd_dataset     = program_name
      and lngd_field       = "det_disc_prnt"
      and lngd_lang        = global_user_lang
      and lngd_translation = input disc_det
   no-lock no-error.
   if not available lngd_det then do:
      /* Invalid Option */
      {pxmsg.i &MSGNUM=712 &ERRORLEVEL=3 &MSGARG1=disc_det}
      {gprun.i ""gpmsgls1.p""
          "(6928, program_name, 'det_disc_prnt', global_user_lang )"}
      next-prompt disc_det with frame a.
      undo, retry.
   end.
   disc_det_key = lngd_key1.

   find first lngd_det where
          lngd_dataset     = program_name
      and lngd_field       = "det_disc_prnt"
      and lngd_lang        = global_user_lang
      and lngd_translation = input disc_sum
   no-lock no-error.
   if not available lngd_det then do:
      /* Invalid Option */
      {pxmsg.i &MSGNUM=712 &ERRORLEVEL=3 &MSGARG1=disc_sum}
      {gprun.i ""gpmsgls1.p""
         "(6928, program_name, 'det_disc_prnt', global_user_lang )"}
      next-prompt disc_sum with frame a.
      undo, retry.
   end.
   disc_sum_key = lngd_key1.

   if not incinv and not incmemo then do:
      {pxmsg.i &MSGNUM=1614 &ERRORLEVEL=3}
      /* Selection criteria results in no data to report */
      next-prompt incinv with frame a.
      undo, retry.
   end.

   {&SOIVRP10-P-TAG13}

   bcdparm = "".
   {&SOIVRP10-P-TAG27}
   {gprun.i ""gpquote.p""
      "(input-output bcdparm, 20,
         inv, inv1,
         nbr, nbr1,
         string(shipdate), string(shipdate1),
         site, site1,
         cust, cust1,
         bill, bill1,
         string(inv_date), string(inv_date1),
         string(print_lotserials), string(print_options),
         string(override_print_hist),
         string(comp_addr),
         form_code,
         string(incinv))"}

   {&SOIVRP10-P-TAG14}

   {mfquoter.i incmemo}
   {mfquoter.i disc_det  }
   {mfquoter.i disc_sum  }
   {mfquoter.i call-detail}
   {mfquoter.i msg}
   {&SOIVRP10-P-TAG28}
   {&SOIVRP10-P-TAG5}

   {gprfile.i}
   {&SOIVRP10-P-TAG29}

   {&SOIVRP10-P-TAG15}

   if search (global_user_lang_dir + "so/soiv10" + run_file + ".r") = ? and
      search (global_user_lang_dir + "so/soiv10" + run_file + ".p") = ? then do:
      {&SOIVRP10-P-TAG30}
      /* FORM CODE NOT INSTALLED */
      {pxmsg.i &MSGNUM=129 &ERRORLEVEL=3}
      next-prompt form_code with frame a.
      undo, retry.
   end. /* IF SEARCH */

   {&SOIVRP10-P-TAG31}
   if comp_addr <> "" then do:
   {&SOIVRP10-P-TAG32}

      find ad_mstr where ad_addr = comp_addr no-lock no-wait no-error.

      if available ad_mstr then do:

         if not can-find(ls_mstr where ls_addr = ad_addr and
                                       ls_type = "company")
         then do:
            {pxmsg.i &MSGNUM=28 &ERRORLEVEL=3}
            /*  Address must be for a company */
            next-prompt comp_addr.
            undo, retry.
         end.

         {&SOIVRP10-P-TAG33}
         assign
            addr[1] = ad_name
            addr[2] = ad_line1
            addr[3] = ad_line2
            addr[4] = ad_line3
            addr[6] = ad_country.

         {mfcsz.i addr[5] ad_city ad_state ad_zip}.

         {&SOIVRP10-P-TAG34}
         {gprun.i ""gpaddr.p"" }

         assign
            company[1] = addr[1]
            company[2] = addr[2]
            company[3] = addr[3]
            company[4] = addr[4]
            company[5] = addr[5]
            company[6] = addr[6].

         /* FIND VAT REG. NO & COUNTRY CODE */
         {gpvtecrg.i}

      end.

      else do:
         {pxmsg.i &MSGNUM=28 &ERRORLEVEL=3}
         /*  Address must be for a company */
         next-prompt comp_addr.
         undo, retry.
      end.

   end.

   {&SOIVRP10-P-TAG35}
   {&SOIVRP10-P-TAG6}
   if form_code = "11"
   or et_ctrl.et_print_dc
   then
      prt_width = 132.
   {&SOIVRP10-P-TAG7}
   else
      prt_width = 80.

   {&SOIVRP10-P-TAG16}

   /* OUTPUT DESTINATION SELECTION */
   {gpselout.i &printType = "printer" &printWidth = prt_width
               &pagedFlag = " "
               &stream = " "
               &appendToFile = " "
               &streamedOutputToTerminal = " "
               &withBatchOption = "yes"
               &displayStatementType = 1
               &withCancelMessage = "yes"
               &pageBottomMargin = 6
               &withEmail = "yes"
               &withWinprint = "yes"
               &defineVariables = "yes"}
/*GUI*/ RECT-FRAME:HEIGHT-PIXELS in frame a = FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.

   {hksimsg.i site site1}

   mainloop:
   do transaction on error undo, leave on endkey undo, leave:

      {gprfile.i}

      pages = 0.

      if nbr1      = "" then nbr1      = hi_char.
      if inv1      = "" then inv1      = hi_char.
      if inv_date  = ?  then inv_date  = low_date.
      if inv_date1 = ?  then inv_date1 = hi_date.
      if shipdate  = ?  then shipdate  = low_date.
      if shipdate1 = ?  then shipdate1 = hi_date.
      if inv1      = "" then inv1      = hi_char.
      if site1     = "" then site1     = hi_char.
      if cust1     = "" then cust1     = hi_char.
      if bill1     = "" then bill1     = hi_char.

      /* DUMMY RUNS FOR BOMS ETC. */

      if false then do:
         {gprun.i ""hksoiv1001.p""}
         {gprun.i ""hksoiv1011.p""}
      end. /* IF FALSE  */

      {&SOIVRP10-P-TAG8}
      {&SOIVRP10-P-TAG17}
      {&SOIVRP10-P-TAG37}
      /* RUN SELECTED FORMAT */
      {gprun.i " ""hksoiv10"" + run_file + "".p"" "}
      {&SOIVRP10-P-TAG38}
      {&SOIVRP10-P-TAG18}
      {&SOIVRP10-P-TAG9}

      {mfreset.i}
/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/


   end.  /* mainloop */
   {&SOIVRP10-P-TAG36}

end.
